<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <div style="width: 100px; height: 100px; background: red" onclick="f()">
        div
    </div>



    <script>

        // js中方法的定义:  function 方法名(参数) {方法体}
        function f() {
            // alert(123)
            document.getElementsByTagName("div")[0].innerText = "123"
        }



    </script>

</body>
</html>
